#!/usr/bin/python3
# -*- coding:utf-8 -*-
""""
@Author: 李吉凯
@Email: lijk34925@hundsun.com
@Time: 2021/11/8 10:41
@File: myTags.py
"""

from django import template
from django.utils.safestring import mark_safe
from requests.compat import basestring

register = template.Library() #前面三行为必须的

@register.simple_tag  #通过@register.simple_tag装饰成标签
def tag_multi(x,y,z):  #返回参数相乘的结果
    return x*y*z

@register.filter  #通过@register.filter装饰成过滤器
def filter_multi(x,y):   #返回参数相乘的结果，装饰器只能接收两个参数
    return x*y

@register.filter
def is_string(val):
    return isinstance(val, basestring)

@register.filter(name="isinstance")
def isinstance_filter(val, instance_type):
    return isinstance(val, eval(instance_type))